package com.aop1;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainAop1 {
    public static void main(String[] args) {
        for (int i = 1; i < 4; i++) {
            String cfg = "aop1/spring_cfg_0" + i + ".xml";
            ApplicationContext ctx = new ClassPathXmlApplicationContext(cfg);
            mgrDaoFun(ctx);
            usrDaoFun(ctx);
        }
    }

    private static void usrDaoFun(ApplicationContext ctx) {
        System.out.println("\n\n=====================");
        UserDao usrDao = (UserDao) ctx.getBean("userDao");
        usrDao.addUser();
        usrDao.delUser();
    }

    private static void mgrDaoFun(ApplicationContext ctx) {
        System.out.println("\n\n=====================");
        ManagerDao mgrDao = (ManagerDao) ctx.getBean("mgrDao");
        mgrDao.addMgr();
        mgrDao.delMgr();
        System.out.println("\n");
    }
}
